home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Games / operation-graduates.swf / scripts / frame_41 / DoAction_4.as < prev    next >
Text File  |  2011-10-17  |  3KB  |  141 lines

  1. function spawnTentacle(xSpot)
  2. {
  3.    var _loc1_ = enemyContainer.attachMovie("tentacle","enemy" + eConCount++,eConCount);
  4.    _loc1_.gotoAndStop(1);
  5.    _loc1_._x = xSpot;
  6.    _loc1_._rotation = Math.atan2(theHull._y - _loc1_._y,theHull._x - _loc1_._x) * 57.29577951308232 - 90;
  7.    _loc1_.myDest = new Vector(theHull._x - _loc1_._x,theHull._y - _loc1_._y);
  8.    _loc1_.myDest.setLength(128);
  9.    _loc1_.t = 0;
  10.    _loc1_.d = 30;
  11.    _loc1_.sX = _loc1_._x;
  12.    _loc1_.cX = _loc1_.myDest.x;
  13.    _loc1_.sY = _loc1_._y;
  14.    _loc1_.cY = _loc1_.myDest.y;
  15.    _loc1_.move = tentacleMover;
  16.    _loc1_.shoot = tentacleShooter;
  17.    _loc1_.hit = tentacleHit;
  18.    _loc1_.isHit = false;
  19.    _loc1_.energy = 70;
  20.    _loc1_.countdown;
  21.    _loc1_.Q1logic = baddyQ1;
  22.    _loc1_.Q2logic = baddyQ2;
  23.    _loc1_.Q3logic = baddyQ3;
  24.    _loc1_.Q4logic = baddyQ4;
  25.    _loc1_.collide = baddyCollide;
  26. }
  27. function tentacleMover()
  28. {
  29.    if(this.isHit)
  30.    {
  31.       this.resetColor();
  32.       this.isHit = false;
  33.    }
  34.    with(this)
  35.    {
  36.       if(t < d)
  37.       {
  38.          t++;
  39.          _x = Math.easeOutQuad(t,sX,cX,d);
  40.          _y = Math.easeOutQuad(t,sY,cY,d);
  41.       }
  42.       if(t == d)
  43.       {
  44.          myDest.reset(theHull._x - _x,theHull._y - _y);
  45.          myDest.setLength(128);
  46.          t = 0;
  47.          d = 5;
  48.          sX = _rotation;
  49.          cX = Math.atan2(theHull._y - _y,theHull._x - _x) * 57.29577951308232 - 90 - _rotation;
  50.          if(cX > 180)
  51.          {
  52.             cX = 360 - cX;
  53.          }
  54.          else if(cX < -180)
  55.          {
  56.             cX = 360 + cX;
  57.          }
  58.          move = tentacleRotator;
  59.       }
  60.    }
  61. }
  62. function tentacleRotator()
  63. {
  64.    if(this.isHit)
  65.    {
  66.       this.resetColor();
  67.       this.isHit = false;
  68.    }
  69.    with(this)
  70.    {
  71.       if(t < d)
  72.       {
  73.          t++;
  74.          _rotation = Math.easeOutQuad(t,sX,cX,d);
  75.       }
  76.       if(t == d)
  77.       {
  78.          gotoAndPlay("shoot");
  79.          t = 0;
  80.          d = 30;
  81.          sX = _x;
  82.          cX = myDest.x;
  83.          sY = _y;
  84.          cY = myDest.y;
  85.          this.countdown = 30;
  86.          move = tentacleCountdown;
  87.       }
  88.    }
  89. }
  90. function tentacleShooter()
  91. {
  92.    var _loc1_ = this;
  93.    var _loc3_ = eBullets.attachMovie("eBul1","bullet" + eBulletsCount++,eBulletsCount);
  94.    var _loc2_ = new Object();
  95.    _loc2_.x = _loc1_.shootspot._x;
  96.    _loc2_.y = _loc1_.shootspot._y;
  97.    _loc1_.localToGlobal(_loc2_);
  98.    _loc3_._x = _loc2_.x;
  99.    _loc3_._y = _loc2_.y;
  100.    _loc3_.vel = _loc1_.myDest.getClone();
  101.    _loc3_.vel.setLength(5);
  102.    _loc3_.onEnterFrame = function()
  103.    {
  104.       var _loc1_ = this;
  105.       _loc1_._x += _loc1_.vel.x;
  106.       _loc1_._y += _loc1_.vel.y;
  107.       if(_loc1_._x < 0 || _loc1_._x > 600 || _loc1_._y < 0 || _loc1_._y > 400)
  108.       {
  109.          _loc1_.removeMovieClip();
  110.       }
  111.    };
  112. }
  113. function tentacleHit()
  114. {
  115.    var _loc1_ = this;
  116.    _loc1_.setRGB(16777215);
  117.    _loc1_.isHit = true;
  118.    _loc1_.energy -= 5;
  119.    if(_loc1_.energy <= 0)
  120.    {
  121.       playSound("sound.missile.explode");
  122.       explode(_loc1_);
  123.       addScore(500);
  124.       baddyKillCount++;
  125.    }
  126. }
  127. function tentacleCountdown()
  128. {
  129.    var _loc1_ = this;
  130.    if(_loc1_.isHit)
  131.    {
  132.       _loc1_.resetColor();
  133.       _loc1_.isHit = false;
  134.    }
  135.    _loc1_.countdown = _loc1_.countdown - 1;
  136.    if(_loc1_.countdown == 0)
  137.    {
  138.       _loc1_.move = tentacleMover;
  139.    }
  140. }
  141.